package com.guchenbo.nacos.java.sdk;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;

import java.util.Properties;

public class JavaSdkDemo {
    public static void main(String[] args) {
        try {
            String serverAddr = "localhost:8848";
            String dataId = "guchenbo";
            String group = "DEFAULT_GROUP";

            Properties properties = new Properties();
            properties.put("serverAddr", serverAddr);
            properties.put("username", "nacos");
            properties.put("password", "nacos");

            ConfigService configService = NacosFactory.createConfigService(properties);
            String content = configService.getConfig(dataId, group, 5000);
            System.out.println(content);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
